package com.tanhua.manager.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tanhua.manager.mapper.PaperMapper;
import com.tanhua.manager.service.PaperService;
import com.tanhua.pojo.Paper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaperServiceImpl extends ServiceImpl<PaperMapper, Paper> implements PaperService {

    @Autowired
    private PaperMapper paperMapper;

    @Override
    public Boolean insertOne(Paper paper) {
        int insert = paperMapper.insert(paper);
        return insert > 0;
    }

    @Override
    public IPage<Paper> findByPage(Integer pageNum, Integer pageSize) {
        IPage<Paper> page = new Page<>(pageNum, pageSize);
        return paperMapper.selectPage(page, null);
    }

    @Override
    public List<Paper> findAll() {
        return paperMapper.selectList(null);
    }

    @Override
    public Paper findById(Integer paperId) {
        return paperMapper.selectById(paperId);
    }

}
